﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using System.Security.Permissions;



namespace hpm
{
    public partial class frmDMNgheNghiep : DevExpress.XtraEditors.XtraForm
    {
        clsNgheNghiep objNgheNghiep = new clsNgheNghiep();

        public frmDMNgheNghiep()
        {
            InitializeComponent();
        }

        private void frmDMNgheNghiep_Load(object sender, EventArgs e)
        {
            InitLstNgheNghiep();
        }

        private void InitLstNgheNghiep()
        {
            grdNgheNghiep.DataSource = objNgheNghiep.GetAll_NgheNghiep();
            grvNgheNghiep.AddNewRow();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            grvNgheNghiep.DeleteRow(grvNgheNghiep.DataRowCount - 1);
            objNgheNghiep.CapNhatNgheNghiep();
        }

        private void grvNgheNghiep_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.ToString() == "Mã Nghề")
            {
                grvNgheNghiep.AddNewRow();
                grvNgheNghiep.FocusedRowHandle = grvNgheNghiep.DataRowCount - 1;
                grvNgheNghiep.FocusedColumn = grvNgheNghiep.VisibleColumns[0];
            }
        }

        private bool CanRequestNotifications()
        {
            // In order to use the callback feature of the
            // SqlDependency, the application must have
            // the SqlClientPermission permission.
            try
            {
                SqlClientPermission perm = new SqlClientPermission(PermissionState.Unrestricted);

                perm.Demand();

                return true;
            }
            catch
            {
                return false;
            }
        }

        
    }
}